<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<div id="paypal-button-container"></div>
<div>
    <#--<button id="customBtn" type="button">Google登录</button>
    <button id="facebookBtn" type="button" onclick="checkLoginState()" >facebook登录</button>
    <div id="name"></div>
    <button type="button" onclick="signOut();">Sign out</button>-->

    <button id="facebookBtn" type="button" onclick="loginFaceBook()" >facebook登录</button>
    <div class="fb-login-button" data-width="" data-size="large" data-button-type="login_with" data-layout="default" scope="email,user_checkins" data-auto-logout-link="false" data-use-continue-as="false"></div>

</div>
</body>
<div id="fb-root"></div>
<#--<script async defer crossorigin="anonymous" src="https://connect.facebook.net/zh_CN/sdk.js#xfbml=1&version=v9.0&appId=471555410476624&autoLogAppEvents=1" nonce="7hh2c63h"></script>
<script src="https://apis.google.com/js/api:client.js"></script>
<script src="https://www.paypal.com/sdk/js?client-id=AcBJqQPyLwUL7VsHMkydcKraU3wsxRSGjEve3MwNcPj34CdQCoswd9e1r6bl50ungwetlnh9xCobEa6s"> // Required. Replace SB_CLIENT_ID with your sandbox client ID.
</script>-->

<script>





    (function(d, s, id){
        var js, fjs = d.getElementsByTagName(s)[0];
        if (d.getElementById(id)) {return;}
        js = d.createElement(s); js.id = id;
        js.src = "https://connect.facebook.net/en_US/sdk.js";
        fjs.parentNode.insertBefore(js, fjs);
    }(document, 'script', 'facebook-jssdk'));
    //初始化
    window.fbAsyncInit = function() {
        FB.init({
            appId: '471555410476624',
            cookie: true,
            xfbml: true,
            version: 'v9.0'
        });

        FB.AppEvents.logPageView();
        //用户登录状态
        FB.getLoginStatus(function(response) {
            console.log(response);
        });

    };

    //登入
    function loginFaceBook(){
        FB.login(function(response){
            getUserInfo();
        })
    }

    // 获取用户信息
    function getUserInfo(){
        FB.api(
            '/me',
            'GET',
            {"fields":"id,name,location,email,first_name,last_name"},
            function(response) {
                console.log(response);
                //api
            }
        );
    }


    function checkLoginState() {
        FB.getLoginStatus(function(response) {
            console.log(response);
        });
    }






</script>
<#--<script>



    createOrders = function() {
        fetch('/aps/pay', {
            method: 'post',
            headers: {
                'content-type': 'application/json'
            }
        }).then(response =>
            response.text()
        ).then(data => {
            console.log(data);
            return data;
        }).catch(function(e){
            console.log("error:" + e);
        })
    }

    async function getOrder() {
        const res = await fetch('/v1/createOrder', {method: 'post', headers: {'content-type': 'application/json'},body: JSON.stringify({ productId: 3,monthType:2 })});
        const result = await res.json();
        return result.Data.orderId;
    }


    paypal.Buttons({
        createOrder: function(data, actions) {
            return getOrder()
        },
        onApprove: function(data, actions) {
            // This function captures the funds from the transaction.
            return actions.order.capture().then(function(details) {
                // This function shows a transaction success message to your buyer.
                alert('Transaction completed by ' + details.payer.name.given_name);
            });
        }
    }).render('#paypal-button-container');


    var googleUser = {};
    var startApp = function() {
        gapi.load('auth2', function(){
            // Retrieve the singleton for the GoogleAuth library and set up the client.
            auth2 = gapi.auth2.init({
                // client_id: '64452377724-ok7d4s1fe1a5sojf7bqmtmsi56pmuc5o.apps.googleusercontent.com', //客户端ID
                client_id: '', //客户端ID
                cookiepolicy: 'single_host_origin',
                scope: 'profile' //可以请求除了默认的'profile' and 'email'之外的数据
            });
            attachSignin(document.getElementById('customBtn'));
        });
    };

    function attachSignin(element) {
        auth2.attachClickHandler(element, {},
            function(googleUser) {
                document.getElementById('name').innerText = "Signed in: " + googleUser.getBasicProfile().getName();
                var profile = auth2.currentUser.get().getBasicProfile();
                console.log('ID: ' + profile.getId());
                console.log('Full Name: ' + profile.getName());
                console.log('Given Name: ' + profile.getGivenName());
                console.log('Family Name: ' + profile.getFamilyName());
                console.log('Image URL: ' + profile.getImageUrl());
                console.log('Email: ' + profile.getEmail());
            }, function(error) {
                console.log(JSON.stringify(error, undefined, 2));
            });
    }
    startApp();

    //注销
    function signOut() {
        var auth2 = gapi.auth2.getAuthInstance();
        auth2.signOut().then(function () {
            alert('用户注销成功');
        });
    }


</script>-->
</html>
